import java.util.HashMap;
import java.util.Map;

// 1533776805
public class P45 {
	private static Map<Long, Long> pentagonalMap = new HashMap<Long, Long>();
	private static Map<Long, Long> hexagonalMap = new HashMap<Long, Long>();
	
	private static long getTriangle(long n) {
		return (n * (n + 1))/2;		
	}
	
	private static long getPentagonal(long n) {
		return (n * (3 * n - 1))/2;		
	}
	
	private static long getHexagonal(long n) {
		return n * (2 * n - 1);		
	}
	
	private static boolean searchPentagonal(long n) {
		if (pentagonalMap.size() == 0) {		
			long x = getPentagonal(1);
			pentagonalMap.put(x, x);
		}
		
		while (true) {
			long x = pentagonalMap.get(getPentagonal(pentagonalMap.size()));
			
			if (x == n) {
				return true;
			} else if (x < n) {
				long y = getPentagonal(pentagonalMap.size() + 1);
				pentagonalMap.put(y, y);
			} else if (x > n) {
				return false;
			}
		}
	}
	
	private static boolean searchHexagonal(long n) {
		if (hexagonalMap.size() == 0) {		
			long x = getHexagonal(1);
			hexagonalMap.put(x, x);
		}
		
		while (true) {
			long x = hexagonalMap.get(getHexagonal(hexagonalMap.size()));
			
			if (x == n) {
				return true;
			} else if (x < n) {
				long y = getHexagonal(hexagonalMap.size() + 1);
				hexagonalMap.put(y, y);
			} else if (x > n) {
				return false;
			}
		}
	}
	
	public static void main(String[] args) {
		for (long i = 1; true; i++) {
			long x = getTriangle(i);
			
			if (searchPentagonal(x)) {
				if (searchHexagonal(x)) {
					System.out.println(x);
				}				
			}
		}
	}
}